﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Tools;

namespace Punia
{
    [CommandAttribute(false)]
    public partial class drop_endpoint : BaseForm
    {
        public drop_endpoint()
            : base()
        {
        }

        public drop_endpoint(DbContext dbContext)
            :base(dbContext)
        {
            InitializeComponent();

            cbEndpoint.DataSource = Utility.endpoints(dbContext);
            cbEndpoint.DisplayMember = "Name";

            cbEndpoint.SelectedIndexChanged += new EventHandler(cbEndpoint_SelectedIndexChanged);
        }

        void cbEndpoint_SelectedIndexChanged(object sender, EventArgs e)
        {
            Write();
        }

        protected override void Write()
        {
            StringBuilder sb = new StringBuilder();

            if (cbEndpoint.SelectedIndex > 0)
            {
                sb.AppendLine("DROP ENDPOINT [" + cbEndpoint.Text + "]");
            }
            tbCommand.Text = sb.ToString();
        }
    }
}